Skip to content

Develop-Fix: 그라파나 datasource UID/대시보드 변수 매칭 수정, main 통합 - #100

Merged
jaebeom79 merged 6 commits into
mainfrom
develop
May 28, 2026
Merged

Develop-Fix: 그라파나 datasource UID/대시보드 변수 매칭 수정, main 통합#100
jaebeom79 merged 6 commits into
mainfrom
develop

Conversation

@johe00123

Copy link
Copy Markdown
Contributor

📢 기능 설명

필요시 실행결과 스크린샷 첨부

연결된 issue

연결된 issue를 자동을 닫기 위해 아래 {이슈넘버}를 입력해주세요.

close #{이슈넘버}

✅ 체크리스트

  • PR 제목 규칙 잘 지켰는가?
  • 추가/수정사항을 설명하였는가?
  • 이슈넘버를 적었는가?

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request increases the container start period in docker-compose, updates Grafana dashboard and datasource configurations, and integrates Micrometer metrics for Kafka and Redis. The review feedback suggests using ObjectProvider<MeterRegistry> in both KafkaConfig and RedisConfig to make the MeterRegistry dependency optional. This prevents application context loading failures in environments or slice tests where the MeterRegistry bean is not registered.

@@ -1,5 +1,6 @@
package com.catchtable.global.config;

import io.micrometer.core.instrument.MeterRegistry;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

ObjectProvider를 사용하기 위해 임포트를 추가합니다.

Suggested change
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.ObjectProvider;

Comment on lines +28 to +32
private final MeterRegistry meterRegistry;

public KafkaConfig(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

테스트 환경이나 특정 프로파일에서 MeterRegistry 빈이 존재하지 않을 경우, NoSuchBeanDefinitionException이 발생하여 애플리케이션 컨텍스트 로드가 실패할 수 있습니다. ObjectProvider<MeterRegistry>를 사용하여 MeterRegistry 주입을 선택적으로 처리하면, 메트릭 수집 빈이 없는 환경에서도 안전하게 컨텍스트를 구동할 수 있습니다.

Suggested change
private final MeterRegistry meterRegistry;
public KafkaConfig(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
}
private final ObjectProvider<MeterRegistry> meterRegistryProvider;
public KafkaConfig(ObjectProvider<MeterRegistry> meterRegistryProvider) {
this.meterRegistryProvider = meterRegistryProvider;
}

Comment on lines +45 to +47
DefaultKafkaProducerFactory<String, Object> factory = new DefaultKafkaProducerFactory<>(config);
factory.addListener(new MicrometerProducerListener<>(meterRegistry));
return factory;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

ObjectProvider<MeterRegistry>를 사용하여 MeterRegistry가 존재할 때만 MicrometerProducerListener를 추가하도록 변경합니다.

        DefaultKafkaProducerFactory<String, Object> factory = new DefaultKafkaProducerFactory<>(config);
        meterRegistryProvider.ifAvailable(meterRegistry ->
                factory.addListener(new MicrometerProducerListener<>(meterRegistry))
        );
        return factory;

Comment on lines +78 to +80
DefaultKafkaConsumerFactory<String, Object> factory = new DefaultKafkaConsumerFactory<>(config);
factory.addListener(new MicrometerConsumerListener<>(meterRegistry));
return factory;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

ObjectProvider<MeterRegistry>를 사용하여 MeterRegistry가 존재할 때만 MicrometerConsumerListener를 추가하도록 변경합니다.

        DefaultKafkaConsumerFactory<String, Object> factory = new DefaultKafkaConsumerFactory<>(config);
        meterRegistryProvider.ifAvailable(meterRegistry ->
                factory.addListener(new MicrometerConsumerListener<>(meterRegistry))
        );
        return factory;

Comment on lines +14 to +20
@Bean(destroyMethod = "shutdown")
public ClientResources lettuceClientResources(MeterRegistry meterRegistry) {
MicrometerOptions options = MicrometerOptions.create();
return DefaultClientResources.builder()
.commandLatencyRecorder(new MicrometerCommandLatencyRecorder(meterRegistry, options))
.build();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

테스트 환경(예: @DataJpaTest 등 슬라이스 테스트)이나 Actuator가 비활성화된 환경에서는 MeterRegistry 빈이 컨텍스트에 등록되지 않아 NoSuchBeanDefinitionException이 발생할 수 있습니다. ObjectProvider<MeterRegistry>를 사용하여 MeterRegistry가 존재할 때만 MicrometerCommandLatencyRecorder를 설정하도록 개선하면 애플리케이션의 견고성을 높일 수 있습니다.

    @Bean(destroyMethod = "shutdown")
    public ClientResources lettuceClientResources(org.springframework.beans.factory.ObjectProvider<MeterRegistry> meterRegistryProvider) {
        DefaultClientResources.Builder builder = DefaultClientResources.builder();
        meterRegistryProvider.ifAvailable(meterRegistry -> {
            MicrometerOptions options = MicrometerOptions.create();
            builder.commandLatencyRecorder(new MicrometerCommandLatencyRecorder(meterRegistry, options));
        });
        return builder.build();
    }

@jaebeom79
jaebeom79 merged commit e78f6c8 into main May 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants